/** ------------------------------------------------------------------------
 *	VisualGroup JavaScript prototype Classes, version draf
 *  (c) 2006 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/

/**
 * Prototype Class : "ValidateTransaction"
 * @prerequire class : 	"Vsg.Common.Logger" 
 */
 
using("Vsg.Common.Logger"); 
 
Vsg.Validator.ValidatorTransaction = Class.create();
Vsg.Validator.ValidatorTransaction.prototype = {
	initialize:function() {
		this.$checkingRef = new Array();
	}
}

/**
 * if the result is true , the result is pass 
 */
Vsg.Validator.ValidatorTransaction.prototype.addCheck = function($ref,$args , $message , $arguObj) {
	var methodObj = new Object();
	methodObj.ref = $ref;
	methodObj.args = $args;
	methodObj.custMessage = $message
	methodObj.arguObjs = $arguObj
	this.$checkingRef.push(methodObj);
}

Vsg.Validator.ValidatorTransaction.prototype.getResult = function() {
	var result = true;
	
	Vsg.Common.Logger.trace("[Vsg.Validator.ValidateTransaction.getResult()] : " + this.$checkingRef);
	var methodObj;
	for (var $i = 0 ; $i < this.$checkingRef.length ; $i++) {
		methodObj = this.$checkingRef[$i].ref;
		
		if (this.$checkingRef[$i].arguObjs != null && this.$checkingRef[$i].custMessage != null) {
			result = methodObj.call(methodObj,this.$checkingRef[$i].args , this.$checkingRef[$i].custMessage ,  this.$checkingRef[$i].arguObjs);
		}
		
		else if (this.$checkingRef[$i].custMessage != null) {
			result = methodObj.call(methodObj,this.$checkingRef[$i].args , this.$checkingRef[$i].custMessage);
		}
		else {
			result = methodObj.call(methodObj,this.$checkingRef[$i].args);
		}
		if (!result) {
			break;
		}
	}
	return result;
}
